home *** CD-ROM | disk | FTP | other *** search
/ An Introduction to Progr…l Basic 6.0 (4th Edition) / An Introduction to Programming using Visual Basic 6.0.iso / PROGRAMS / CH12 / 12-2-2.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-09-23  |  2.6 KB  |  84 lines

  1. VERSION 5.00
  2. Begin VB.Form frmDBMan 
  3.    Caption         =   "Example 12-2-2"
  4.    ClientHeight    =   1440
  5.    ClientLeft      =   1116
  6.    ClientTop       =   1512
  7.    ClientWidth     =   4284
  8.    LinkTopic       =   "Form1"
  9.    PaletteMode     =   1  'UseZOrder
  10.    ScaleHeight     =   1440
  11.    ScaleWidth      =   4284
  12.    Begin VB.ListBox lstCities 
  13.       Height          =   624
  14.       Left            =   2880
  15.       TabIndex        =   3
  16.       Top             =   120
  17.       Width           =   1215
  18.    End
  19.    Begin VB.CommandButton cmdFind 
  20.       Caption         =   "Find Cities"
  21.       Height          =   495
  22.       Left            =   120
  23.       TabIndex        =   2
  24.       Top             =   480
  25.       Width           =   2535
  26.    End
  27.    Begin VB.TextBox txtCountry 
  28.       Height          =   285
  29.       Left            =   840
  30.       TabIndex        =   0
  31.       Top             =   120
  32.       Width           =   1815
  33.    End
  34.    Begin VB.Data datCities 
  35.       Caption         =   "Large World Cities"
  36.       Connect         =   "Access"
  37.       DatabaseName    =   "MEGACTY2.MDB"
  38.       DefaultCursorType=   0  'DefaultCursor
  39.       DefaultType     =   2  'UseODBC
  40.       Exclusive       =   0   'False
  41.       Height          =   300
  42.       Left            =   120
  43.       Options         =   0
  44.       ReadOnly        =   0   'False
  45.       RecordsetType   =   1  'Dynaset
  46.       RecordSource    =   "SELECT * FROM Cities ORDER BY city ASC"
  47.       Top             =   1080
  48.       Width           =   2655
  49.    End
  50.    Begin VB.Label lblCountry 
  51.       Caption         =   "Country"
  52.       Height          =   255
  53.       Left            =   120
  54.       TabIndex        =   1
  55.       Top             =   120
  56.       Width           =   615
  57.    End
  58. Attribute VB_Name = "frmDBMan"
  59. Attribute VB_GlobalNameSpace = False
  60. Attribute VB_Creatable = False
  61. Attribute VB_PredeclaredId = True
  62. Attribute VB_Exposed = False
  63. Private Sub cmdFind_Click()
  64.   Dim nom As String, criteria As String
  65.   lstCities.Clear
  66.   If txtCountry.Text <> "" Then
  67.       nom = txtCountry.Text
  68.       criteria = "country = " & "'" & nom & "'"
  69.       datCities.Recordset.FindFirst criteria
  70.       Do While datCities.Recordset.NoMatch = False
  71.         lstCities.AddItem datCities.Recordset.Fields("city").Value
  72.         datCities.Recordset.FindNext criteria
  73.       Loop
  74.       If lstCities.ListCount = 0 Then lstCities.AddItem "None"
  75.     Else
  76.       MsgBox "You must enter a country.", , ""
  77.       txtCountry.SetFocus
  78.     End If
  79. End Sub
  80. Private Sub Form_Load()
  81.   'Look for the data base in the same folder as the program
  82.   datCities.DatabaseName = App.Path & "\MEGACTY2.MDB"
  83. End Sub
  84.